package com.example.hbase;

import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

public class StudentReducer extends Reducer<Text, IntWritable, Text, IntWritable> {

    @Override
    public void reduce(Text key, Iterable<IntWritable> values, Context ctx) throws IOException, InterruptedException {
        int sum = 0, count = 0;
        for(IntWritable val:values){
        	sum+=val.get();
        	count++;
        }
        int avg = sum / count;
        key = new Text("Average height: ");
        ctx.write(key, new IntWritable(avg));
    }

}
